package com.abe.jetpack.model.room

import android.arch.persistence.room.Dao
import android.arch.persistence.room.Delete
import android.arch.persistence.room.Insert
import android.arch.persistence.room.Query
import com.abe.jetpack.model.entity.http.AuthorEntity
import io.reactivex.Single

@Dao
interface AuthorDao {
    @Query("SELECT * FROM AuthorEntity")
    fun getAll(): Single<List<AuthorEntity>>

    @Query("SELECT * FROM AuthorEntity WHERE id IN (:ids)")
    fun loadAllByIds(ids: Array<String>): Single<List<AuthorEntity>>

    @Query("SELECT * FROM AuthorEntity WHERE name = :authorName")
    fun findByName(authorName: String): Single<AuthorEntity>

    @Insert
    fun insertAll(vararg authorEntity: AuthorEntity)

    @Delete
    fun delete(authorEntity: AuthorEntity)
}